<template>
	<view style="width: 100vw;position: relative;">

		<!-- <status-bar></status-bar> -->
		<myLoading v-if="isLoading"></myLoading>
		<template v-else>

			<image  style="width: 100%;margin-top: -30rpx;" :src="imgurl" mode="widthFix">
			</image>
<!-- 			<image v-else style="width: 100%;margin-top: -30rpx;" src="../../static/10.jpg" mode="widthFix"></image> -->


			<view @click="setImg(9)" style="position: absolute;left:0px;top: 600rpx;width: 50%;height: 130rpx;">
			</view>
			<view @click="setImg(10)" style="position: absolute;right:0px;top: 600rpx;width: 50%;height: 130rpx;">
			</view>


			<view v-if="index == 10"
				style="position: absolute;left:35rpx;top: 780rpx;width: 30%;height: 80rpx;background-color: #fafafa;color: #fc7820;font-weight: 600;display: flex;align-items: center;padding-left: 25rpx;font-size: 30rpx;">
				{{ formData.licensePlate }}
			</view>

			<view v-if="index == 10"
				style="position: absolute;right:35rpx;top: 780rpx;width: 40%;height: 80rpx;color: #fc7820;font-weight: 400;display: flex;align-items: center;padding-left: 25rpx;font-size: 30rpx;" @click='golist'>
				
			</view>

			<view @click="goBack" style="width: 200rpx;height: 155rpx;position: absolute;left: 0;top: 0;"></view>

		</template>
	</view>
</template>

<script>

import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
export default {
	components: {
		uniIcons
	},
	data() {
		return {
			isLoading: true,
			isone: true,
			formData: {
				name: '',
				phone: '',
				idCard: '',
				firstReceiveDate: '',
				avatar: ''
			},
			index:9
		}
	},
	onLoad() {

		// 定义一个0.3-1的随机数
		let randomNum = Math.random() * 0.7 + 0.3;
		// 转换为毫秒
		let randomDelay = randomNum * 1000;
		// 延迟执行
		setTimeout(() => {
			setTimeout(() => {
				this.isLoading = false
			}, randomDelay)
		})
	},
	onShow() {
		this.loadUserData();
	},
	computed:{
		imgurl(){
				return `../../static/${this.index}.jpg`
		}
	},
	methods: {
		setImg(index){
				this.index = index
		},
		goMy() {
			uni.navigateTo({
				url: '/pages/my/my'
			})
		},
		loadUserData() {
				const userData = uni.getStorageSync('userInfo');
			console.log(':', userData);
			if (userData) {
				const parsedData = JSON.parse(userData);
				console.log('成功加载本地存储的数据:', parsedData);
				this.formData = parsedData;
				console.log('成功加载本地存储的数据:', this.formData);
			}
		},
		goBack() {
			uni.navigateBack();
		},
		golist(){
			uni.navigateTo({
				url:'/pages/heguiList/heguiList'
			})
		}
	}
}

</script>

<style lang="scss" scoped></style>
